<?php

class ReportController extends Controller
{
	/**
	 * @var string specifies the default action to be 'list'.
	 */
	public $defaultAction='render';

	/**
	 * @var CActiveRecord the currently loaded data model instance.
	 */
	private $_model;

	/**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
			'accessControl', // perform access control for CRUD operations
		);
	}

	/**
	 * Specifies the access control rules.
	 * This method is used by the 'accessControl' filter.
	 * @return array access control rules
	 */
	public function accessRules()
	{
		return array(
			array('allow', // allow authenticated user to perform 'create' and 'update' actions
				'actions'=>array('render'),
				'users'=>array('@'),
			),
			array('deny',  // deny all users
				'users'=>array('*'),
			),
		);
	}

	/**
	 * Shows a particular model.
	 */
	public function actionRender() {
		$c = $_GET['c'];
		$t = $_GET['t'];
		if($c == '' || $t == '')
			throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
		$template = $t.'_'.$c;
		$renderType = $_GET['type'];
		if($renderType != 'html' || $renderType != 'pdf' || $renderType == null)
			$renderType = 'html';
		$this->render($renderType.'/'.$template);
	}
}
